package com.example.project.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.project.entity.Book;
import com.example.project.mapper.BookMapper;

/**
 * 图书信息Controller
 *
 * @author changyao
 * @date 2024-12-04
 */
@RestController
@RequestMapping("/project/book")
public class BookController
{
    @Autowired
    private BookMapper bookMapper;

    /**
     * 查询图书信息列表
     */
    @GetMapping("/list")
    public List<Book> list(Book book)
    {
        QueryWrapper<Book> queryWrapper=new QueryWrapper<>();



        return bookMapper.selectList(queryWrapper);
    }




    /**
     * 获取图书信息详细信息
     */
    @PostMapping("/detil")
    public Book getInfo(@RequestBody Book book)
    {
        return bookMapper.selectById(book);
    }


    /**
     * 新增图书信息
     */
    @PostMapping("/add")
    public int add(@RequestBody Book book)
    {
        return bookMapper.insert(book);
    }

    /**
     * 修改图书信息
     */
    @PostMapping("/edit")
    public int edit(@RequestBody Book book)
    {
        return bookMapper.updateById(book);
    }

    /**
     * 删除图书信息
     */
	@PostMapping("/del")
    public int remove(@RequestBody Book book)
    {
        return bookMapper.deleteById(book);
    }
}
